#! /usr/bin/env python
# -*- coding: utf-8 -*-


class MinStack:

    def __init__(self):
        self._stack = []
        self._min = None

    def push(self, number):
        # write your code here
        self._stack.append(number)

        if not self._min or self._min > number:
            self._min = number

    def pop(self):
        assert self._stack
        self._min = None
        return self._stack.pop()

    def min(self):
        self._min = self._min or self._calc_min()
        print(self._min)
        return self._min

    def _calc_min(self):
        assert not self._min
        if not self._stack:
            return None
        return min(self._stack)

def main():
    print("start main")

    s = MinStack()
    s.push(1)
    s.pop()
    s.push(2)
    s.push(3)
    s.min()
    s.push(1)
    s.min()

if __name__ == "__main__":
    main()
